<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="/publico/template.xhtml">
        <ui:define name="content">
            <h:form id="fprincipal">
                <p:panel header="Tabela de Nutrientes">
                    <p:dataTable id="dt-nutriente" 
                                 value="#{nutrienteBean.nutrientes}" 
                                 var="nutriente"
                                 emptyMessage="sem registros">
                        <f:facet name="header">
                            <div align="left">
                                <p:button outcome="/admin/nutriente/nutriente.xhtml"
                                          value="Novo"
                                          icon="ui-icon-plus"/>
                            </div>
                        </f:facet>

                        <p:column headerText="Id" width="100" class="center">
                            <h:outputLabel value="#{nutriente.id}"/>
                        </p:column>

                        <p:column filterBy="#{nutriente.nome}" headerText="Nome">
                            <h:outputLabel value="#{nutriente.nome}"/>
                        </p:column>

                        <p:column filterBy="#{nutriente.tipo}" headerText="Tipo">
                            <h:outputLabel value="#{nutriente.tipo}"/>
                        </p:column>

                        <p:column class="center" width="55">
                            <p:commandButton 
                                ajax="false" 
                                action="/admin/nutriente/nutriente.xhtml"
                                icon="ui-icon-pencil">
                                <f:setPropertyActionListener 
                                    target="#{nutrienteBean.nutriente}"
                                    value="#{nutriente}"/>
                            </p:commandButton>
                        </p:column>

                        <p:column class="center" width="55">
                            <p:commandButton ajax="false" 
                                             icon="ui-icon-trash"
                                             onclick="return confirm('Você tem certeza?')"
                                             action="#{nutrienteBean.excluir()}">
                                <f:setPropertyActionListener 
                                    target="#{nutrienteBean.nutriente}" 
                                    value="#{nutriente}"/>
                            </p:commandButton>
                        </p:column>
                    </p:dataTable>
                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>
</html>
